package com.code.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
public class WebConfig1 extends WebMvcConfigurationSupport {
    @Override
    public  void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/dishPic/**").addResourceLocations("file:"+"/Users/mac/Desktop/后端/order-server/dishPic/");
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") // 允许所有路径
                .allowedOrigins("*") //允许所有域名
                .allowedMethods("*") //允许所有请求方法
                .allowCredentials(true); // 需要证书
    }
}
